package com.example.listview;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class MainActivity extends Activity {
	private ListView lv1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        lv1=(ListView) findViewById(R.id.listview1);
        
        List<Map<String, Object>> data=new ArrayList<Map<String, Object>>();
      /* Map<String, Object> item1=new HashMap<String, Object>();
        item1.put("pic", R.drawable.ic_launcher);
        item1.put("name", "luxiaofei");
        data.add(item1);*/
        for(int i=0;i<10;i++)
        {
        	Map<String, Object> item1=new HashMap<String, Object>();
            item1.put("pic", R.drawable.ic_launcher);
            item1.put("name", "luxiaofei"+i);
            data.add(item1);
        }
        SimpleAdapter adapter=new SimpleAdapter(this, data, R.layout.listview, new String[]{"pic","name"}, new int[]{R.id.imageview,R.id.textview});
        lv1.setAdapter(adapter);
        
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}
